<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<hr>
<ol class="nostyle">
	<s:if test="#request.assessPojos==null || #request.assessPojos.size<=0">
		<li>
			<p>暂无相关评分人员数据</p>
		</li>
	</s:if>
	<s:else>
		<s:iterator var="assess" status="sta" value="#request.assessPojos">
			<s:if
				test="#assess.name.equals(#session.com_sihai_ehr_session_user_name)">
			<li><p class="title1">
					${assess.name}(<span id="assess_date_${assess.workId}_${weightId}"> <s:if
							test="#assess.assessDate == null">还未做评论</s:if> <s:else>
							<fmt:formatDate value="${assess.assessDate}" pattern="yyyy年MM月dd" />
						</s:else>
					</span> )<a href="javascript:void(0)"
						id="simple-button${assess.workId}-${weightId}" class="button"
						style="float: right"><span class="icon"
						style="background: url(${ctx}/images/img/page.png)">&nbsp;</span><span
						id="assess_score_${assess.workId}_${weightId}"><s:if
								test="#assess.score > 0">${assess.score}</s:if> <s:else>打分</s:else></span></a>
				<div id="simple-popover${assess.workId}-${weightId}" class="popover">
					<header> 评价打分 </header>
					<section>
						<div class="content">
							<form id="post_form_${assess.workId}_${weightId}" name="post_form">
								<input type="hidden" name="assessId" value="${assess.id}" /> <input
									type="hidden" name="planId" value="${assess.planId}" /> <input
									type="hidden" name="weightId" value="${assess.weightId}" /> <input
									type="hidden" name="workId" value="${assess.workId}" /> <input
									type="hidden" name="weightTitle" value="${weightTitle}" /><input
										type="hidden" name="assessType" value="1" />
								<nav>
									<ul>
										<li class="read" style="padding-top: 10px"><a><span
												class="avatar"></span> <textarea name="txt_content" cols="35"
													rows="3" id="txt_content_${assess.workId}_${weightId}" placeholder="请输入评价文字"></textarea> </a><a>
										</a></li>

										<li class="read"><a><span class="avatar"></span> <input
												name="txt_score" type="text" id="txt_score_${assess.workId}_${weightId}" size="10"
												placeholder="请输入评价分值" />


												<button class="button" type="button" onclick="checkForm(${assess.workId},${weightId})">
													<span class="icon"
														style="background: url(images/img/calculator_add.png)">&nbsp;</span>确定
												</button> </a><a> </a></li>
									</ul>
								</nav>
							</form>
						</div>
					</section>
				</div> <script>
					$(document).ready(
							function() {
								$('#simple-button${assess.workId}-${weightId}').popover(
										'#simple-popover${assess.workId}-${weightId}', {});
								$('#top-button').popover('#top-popover', {
									preventLeft : true,
									preventRight : true,
									preventBottom : true
								});
							});
				</script>

				</p>
				<p id="assess_content_${assess.workId}_${weightId}">${assess.assessContent}</p></li>
			</s:if>
			<s:else>
				<li><p class="title1">
						${assess.name}(<span id="assess_date_${assess.workId}_${weightId}"> <s:if
							test="#assess.assessDate == null">还未做评论</s:if> <s:else>
							<fmt:formatDate value="${assess.assessDate}" pattern="yyyy年MM月dd" />
						</s:else>
					</span> )
						<s:if test="#assess.assessDate != null">
						<button type="reset" class="button" style="float: right">
							<span style="background: url(images/img/page.png)" class="icon">&nbsp;</span>${assess.score}分
						</button>
						</s:if>
					</p>
					<p>${assess.assessContent}</p></li>
			</s:else>
		</s:iterator>
	</s:else>
</ol>

<script type="text/javascript">
	Date.prototype.Format = function(formatStr)
	{
		var str = formatStr;
		var Week = ['日','一','二','三','四','五','六'];
		str=str.replace(/yyyy|YYYY/,this.getFullYear());
		str=str.replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100));
		str=str.replace(/MM/,this.getMonth()>9?(this.getMonth()+1).toString():'0' + (this.getMonth() + 1));
		str=str.replace(/M/g,this.getMonth());
		str=str.replace(/w|W/g,Week[this.getDay()]);
		str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate());
		str=str.replace(/d|D/g,this.getDate());
		str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours());
		str=str.replace(/h|H/g,this.getHours());
		str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0' + this.getMinutes());
		str=str.replace(/m/g,this.getMinutes());
		str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0' + this.getSeconds());
		str=str.replace(/s|S/g,this.getSeconds());
		return str;
	} 
	
	function checkForm(workId,weightId) {
		//alert($("#txt_score_" + workId + "_" + weightId).val());
		if ($("#txt_score_" + workId + "_" + weightId).val() == null || $("#txt_score_" + workId + "_" + weightId).val() == "") {
			alert("请输入分数");
			return;
		}
		//isNaN($(this).val())
		if (isNaN($("#txt_score_" + workId + "_" + weightId).val())) {
			alert("请输入有效分数");
			return;
		}

		if ($("#txt_content_" + workId + "_" + weightId).val() == null
				|| $("#txt_content_" + workId + "_" + weightId).val() == "") {
			alert("请输入评价内容");
			return;
		}

		var url = "${ctx}/train/post_assess.xhtml";
		$
				.ajax(
						url,
						{
							type : "POST",
							data : $("#post_form_" + workId + "_" + weightId).serialize(),
							dataType : "html",
							cache : false,
							success : function(a) {
								alert("提交成功");
								var mDate = new Date();
								$("#assess_date_" + workId + "_" + weightId).html(mDate.Format("yyyy年MM月dd"));
								$("#assess_score_" + workId + "_" + weightId).html($("#txt_score_" + workId + "_" + weightId).val() + "分");
								$("#assess_content_" + workId + "_" + weightId).html($("#txt_content_" + workId + "_" + weightId).val());
								
							},
							error : function(XMLHttpRequest, textStatus,
									errorThrown) {
								alert('提交申请发生异常');
							},
							complete : function() {
							}
						});

	}

	

	

	
</script>